<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isSymmetric = function (root) {
      let check = (p, q) => {
        if (p == null || q == null) return p == q;
        // 每个树的右子树都与这棵树的左子树镜像对称
        return p.val == q.val && check(p.left, q.right) && check(p.right, q.left);
      };
      return check(root, root);
    };
  </script>
</body>

</html>